FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# 安装必要的依赖项
RUN apt-get update && apt-get install -y \
    	curl sudo rsync \
    	vim bc \
    	nano \
    	less \
    	man  \
	locales \
    	file git ssh make gcc libssl-dev liblz4-tool expect \
	g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
	qemu-user-static live-build bison flex fakeroot cmake gcc-multilib \
	g++-multilib unzip device-tree-compiler ncurses-dev libgucharmap-2-90-dev \
	bzip2 expat gpgv2 cpp-aarch64-linux-gnu time mtd-utils \
	libreadline-dev \
	libical-dev \
	libdw-dev  \
	libgmp-dev libmpc-dev \
	rsync	 u-boot-tools 


#	python-docutils \
# python-is-python3


# sudo apt install python3-docutils

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8


ARG user=test

# 创建一个用户来运行 Yocto 构建（避免使用 root 用户）
RUN useradd -ms /bin/bash  ${user} && \
    echo "${user}:${user}" | chpasswd && \
    usermod -aG sudo ${user}

# 添加deadsnakes PPA源以安装Python 2.7
RUN apt-get install -y software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get update

# 安装Python 2.7
RUN apt-get install -y python2.7 python-pip  python3-docutils


# 创建 /SDK/ 目录并设置所有者为 ${user}
RUN mkdir -p /SDK && chown -R ${user}:${user} /SDK

# 设置工作目录
WORKDIR /SDK

# 将需求文件复制到工作目录
# COPY requirements.txt .

# 安装Python依赖项
# RUN pip install --no-cache-dir -r requirements.txt

RUN update-alternatives --install /usr/bin/python python /usr/bin/python2.7  2
# RUN update-alternatives --install /usr/bin/python  python /usr/bin/python3    3

# 切换到新创建的用户
USER ${user}

